{literal}
var Chat = {
  initialize: function() {
    new PeriodicalExecuter(this.update, 1);
    Event.observe($("message"), "keypress", this.onKeyPress, false);
  },

  update: function() {
{/literal}
    {ajax_update update_id="chat_log" function="get_messages"}
{literal}
  },

  getParams: function() {
    return { message: $F("message") }
  },

  onKeyPress: function(e) {
    if (e.keyCode == Event.KEY_RETURN) $("send").click();
  },

  onMessageSent: function() {
    Field.clear("message");
    Field.focus("message");
  }
}
Chat.initialize();
{/literal}